/*
	contains the entry function for Toolkit

	Author: Aidan Goddard 23/7/14
*/

#define WIN32_LEAN_AND_MEAN
#include<Windows.h>
#include<Window.h>
#include"VisualStyles.h"

extern void create_main_window();


int WINAPI WinMain(HINSTANCE h_instance, 
				   HINSTANCE prev_instance, 
				   LPSTR cmd_line,
				   int cmd_show)
{
	// init visual styles
	INITCOMMONCONTROLSEX common_controls;
	common_controls.dwSize = sizeof(INITCOMMONCONTROLSEX);
	common_controls.dwICC = ICC_STANDARD_CLASSES;
	if(!InitCommonControlsEx(&common_controls))
	{
		MessageBox(NULL, L"Could not initialise common controls.", NULL, MB_OK | MB_ICONERROR);
		return -1;
	}

	// initialise window system
	int e = Snowstorm::Window::Initialise(Snowstorm::MODE_MULTIPLE);
	if(e != INIT_SUCCESS)
	{
		MessageBox(NULL, L"Could not initialise the window subsystem.", NULL, MB_OK | MB_ICONERROR);
		return -1;
	}

	// create the main window
	create_main_window();

	// perform the windows message loop
	while(Snowstorm::Window::MessageLoop()){}

	// finished successfully
	return 0;
}